﻿<h4 class="about-title">Liên hệ</h4>

<?php
global $db;  
if (isset($_POST['submit'])) {
	$fullname = urldecode(stripslashes($_POST['fullname']));
	$address = urldecode(stripslashes($_POST['address']));
	$content = urldecode(stripslashes($_POST['content']));
	$email = urldecode(stripslashes($_POST['email']));
	$phone = urldecode(stripslashes($_POST['phone']));
	$created = date('Y-m-d h:i:s');

	$sql = "insert into contact (fullname,address,content,email,phone,created) values 
						('{$fullname}','{$address}','{$content}','{$email}','{$phone}','{$created}')";
	if ($db->query($sql)) notice("Đã gửi góp ý của bạn tới ban quản trị website.");
	else notice("Lỗi: chưa cập nhật được.");
}
?>

<form id="add-contact" method="post" action="index.php?mod=contact">
	<p class="contact-row">
		<label class="contact-label">Họ tên</label>
		<input name="fullname" type="text" class="contact-input required" />
	</p>
	<p class="contact-row">
		<label class="contact-label">Địa chỉ</label>
		<input name="address" type="text" class="contact-input required" />
	</p>
	<p class="contact-row">
		<label class="contact-label">Email</label>
		<input name="email" type="text" class="contact-input required enail" />
	</p>
	<p class="contact-row">
		<label class="contact-label">Phone</label>
		<input name="phone" type="text" class="contact-input required" >
	</p>
	<p class="contact-row">
		<label class="contact-label">Nội dung</label>
		<textarea name="content" class="contact-content required"></textarea>
	</p>
	<p class="contact-row">
		<input type="submit" name="submit" class="button" value="Cập nhật" />
		<input type="reset" name="reset" class="button" value="Hủy" />
	</p>
</form>
	
<script>
$("#add-contact").validate();
</script>